﻿<!-- 
Filename: DropDownTheme.xaml
Version: 20150108
-->

<ResourceDictionary
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:local="clr-namespace:FlipPanel;assembly=FlipPanel">

  <ControlTemplate x:Key="FlipPanel_DropDownTemplate" TargetType="local:FlipPanel">
    <Grid Name="LayoutRoot"
      HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
      VerticalAlignment="{TemplateBinding VerticalAlignment}"
      > <!-- need LayoutRoot to hold (and programmatically find) the VSM-->

      <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="ViewStates">
          <VisualStateGroup.Transitions>
            <VisualTransition GeneratedDuration="0:0:0.5">
            </VisualTransition>
          </VisualStateGroup.Transitions>

          <VisualState x:Name="Normal">
            <Storyboard>
              <DoubleAnimation Storyboard.TargetName="BackContentTransform"
                       Storyboard.TargetProperty="ScaleY" To="0" Duration="0:0:0"></DoubleAnimation>
<!--
              <DoubleAnimation Storyboard.TargetName="BackContentEffect" 
                       Storyboard.TargetProperty="Radius" To="30" Duration="0:0:0"></DoubleAnimation>
-->
            </Storyboard>
          </VisualState>

          <VisualState x:Name="Flipped">
            <Storyboard>
              <DoubleAnimation Storyboard.TargetName="FrontContentTransform"
                       Storyboard.TargetProperty="ScaleY" To="0" Duration="0:0:0"></DoubleAnimation>
<!--
              <DoubleAnimation Storyboard.TargetName="FrontContentEffect" 
                       Storyboard.TargetProperty="Radius" To="30" Duration="0:0:0"></DoubleAnimation>
-->
            </Storyboard>
          </VisualState>
        </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>

      <Grid.RowDefinitions>
        <RowDefinition Height="*" />
      </Grid.RowDefinitions>

      <!-- This is the front content. -->
      <Border Grid.Row="0"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              CornerRadius="{TemplateBinding CornerRadius}"
              Background="{TemplateBinding Background}" 
              >

        <Border.RenderTransform>
          <ScaleTransform x:Name="FrontContentTransform"></ScaleTransform>
        </Border.RenderTransform>

        <!-- //Note: removed, causes content to not be h/w accelerated on desktop Silverlight, plus not available on Windows Phone        
        <Border.Effect>
          <BlurEffect x:Name="FrontContentEffect" Radius="0"></BlurEffect>
        </Border.Effect>
        -->

        <ContentPresenter Content="{TemplateBinding FrontContent}" 
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          />

      </Border>

      <!-- Back content -->
      <Border Grid.Row="0" 
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              CornerRadius="{TemplateBinding CornerRadius}"
              Background="{TemplateBinding Background}" 
              RenderTransformOrigin="0,1">

        <Border.RenderTransform>
          <ScaleTransform x:Name="BackContentTransform"></ScaleTransform>
        </Border.RenderTransform>

        <!-- //Note: removed, causes content to not be h/w accelerated on desktop Silverlight, plus not available on Windows Phone        
        <Border.Effect>
          <BlurEffect x:Name="BackContentEffect" Radius="0"></BlurEffect>
        </Border.Effect>
        -->
        
        <ContentPresenter Content="{TemplateBinding BackContent}"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"                          
                          />

      </Border>

    </Grid>

  </ControlTemplate>

  <Style x:Key="FlipPanel_DropDownStyle" TargetType="local:FlipPanel">
    <Setter Property="Template" Value="{StaticResource FlipPanel_DropDownTemplate}"/>
  </Style>

</ResourceDictionary>
